<!DOCTYPE html><html lang="zh-CN" data-theme="dark"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Ant Design 组件使用随笔 | 北城韩雨</title><meta name="keywords" content="React"><meta name="author" content="北城韩雨"><meta name="copyright" content="北城韩雨"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#0d0d0d"><meta name="description" content="React UI组件">
<meta property="og:type" content="article">
<meta property="og:title" content="Ant Design 组件使用随笔">
<meta property="og:url" content="http://example.com/2019/03/21/react-antd%E9%9A%8F%E7%AC%94/index.html">
<meta property="og:site_name" content="北城韩雨">
<meta property="og:description" content="React UI组件">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic.vjshi.com%2F2018-07-17%2Faf41dabad727ba80c9ca8a2bfbd22a58%2F00004.jpg%3Fx-oss-process%3Dstyle%2Fwatermark&refer=http%3A%2F%2Fpic.vjshi.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1629530659&t=bbcfe1e86f393eecbb0722db1b92e475">
<meta property="article:published_time" content="2019-03-20T16:00:00.000Z">
<meta property="article:modified_time" content="2019-06-02T16:00:00.000Z">
<meta property="article:author" content="北城韩雨">
<meta property="article:tag" content="Ant Design">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic.vjshi.com%2F2018-07-17%2Faf41dabad727ba80c9ca8a2bfbd22a58%2F00004.jpg%3Fx-oss-process%3Dstyle%2Fwatermark&refer=http%3A%2F%2Fpic.vjshi.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1629530659&t=bbcfe1e86f393eecbb0722db1b92e475"><link rel="shortcut icon" href="/img/favicon.png"><link rel="canonical" href="http://example.com/2019/03/21/react-antd%E9%9A%8F%E7%AC%94/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: undefined,
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'mediumZoom',
  Snackbar: undefined,
  source: {
    jQuery: 'https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js',
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
    },
    fancybox: {
      js: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js',
      css: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isanchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'Ant Design 组件使用随笔',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2019-06-03 00:00:00'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
    const detectApple = () => {
      if (GLOBAL_CONFIG_SITE.isHome && /iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><link rel="stylesheet" href="/css/custom.css"  media="defer" onload="this.media='all'"><link rel="stylesheet" href="/css/coin.css"  media="defer" onload="this.media='all'"><link rel="stylesheet" href="/css/liuxing.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/l-lin/font-awesome-animation/dist/font-awesome-animation.min.css"  media="defer" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swiper/swiper-bundle.min.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/zhheo/JS-Heo@main/bb/showbb_in_index.css"><!-- hexo injector head_end start --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css" media="print" onload="this.media='screen'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/l-lin/font-awesome-animation/dist/font-awesome-animation.min.css" media="defer" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/hexo-butterfly-tag-plugins-plus/lib/tag_plugins.min.css" media="defer" onload="this.media='all'"><!-- hexo injector head_end end --><meta name="generator" content="Hexo 5.3.0"></head><body><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="/img/my.jpg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data"><div class="data-item is-center"><div class="data-item-link"><a href="/archives/"><div class="headline">文章</div><div class="length-num">65</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/tags/"><div class="headline">标签</div><div class="length-num">23</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/categories/"><div class="headline">分类</div><div class="length-num">21</div></a></div></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page faa-parent animated-hover" href="/"><i class="fa-fw fas fa-home faa-tada"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page faa-parent animated-hover" href="/shuoshuo/"><i class="fa-fw fas fa-archive faa-tada"></i><span> 叨逼叨</span></a></div><div class="menus_item"><a class="site-page faa-parent animated-hover" href="/tags/"><i class="fa-fw fas fa-tags faa-tada"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page faa-parent animated-hover" href="/categories/"><i class="fa-fw fas fa-folder-open faa-tada"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page faa-parent animated-hover" href="/link/"><i class="fa-fw fas fa-link faa-tada"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page faa-parent animated-hover" href="/comments/"><svg class="icon faa-tada" aria-hidden="true"><use xlink:href="#icon-message"></use></svg><span> 留言板</span></a></div><div class="menus_item"><a class="site-page faa-parent animated-hover" href="/about/"><i class="fa-fw fas fa-heart faa-tada"></i><span> 个人简介</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic.vjshi.com%2F2018-07-17%2Faf41dabad727ba80c9ca8a2bfbd22a58%2F00004.jpg%3Fx-oss-process%3Dstyle%2Fwatermark&amp;refer=http%3A%2F%2Fpic.vjshi.com&amp;app=2002&amp;size=f9999,10000&amp;q=a80&amp;n=0&amp;g=0n&amp;fmt=jpeg?sec=1629530659&amp;t=bbcfe1e86f393eecbb0722db1b92e475')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">北城韩雨</a></span><div id="menus"><div class="menus_items"><div class="menus_item"><a class="site-page faa-parent animated-hover" href="/"><i class="fa-fw fas fa-home faa-tada"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page faa-parent animated-hover" href="/shuoshuo/"><i class="fa-fw fas fa-archive faa-tada"></i><span> 叨逼叨</span></a></div><div class="menus_item"><a class="site-page faa-parent animated-hover" href="/tags/"><i class="fa-fw fas fa-tags faa-tada"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page faa-parent animated-hover" href="/categories/"><i class="fa-fw fas fa-folder-open faa-tada"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page faa-parent animated-hover" href="/link/"><i class="fa-fw fas fa-link faa-tada"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page faa-parent animated-hover" href="/comments/"><svg class="icon faa-tada" aria-hidden="true"><use xlink:href="#icon-message"></use></svg><span> 留言板</span></a></div><div class="menus_item"><a class="site-page faa-parent animated-hover" href="/about/"><i class="fa-fw fas fa-heart faa-tada"></i><span> 个人简介</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">Ant Design 组件使用随笔</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2019-03-20T16:00:00.000Z" title="发表于 2019-03-21 00:00:00">2019-03-21</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2019-06-02T16:00:00.000Z" title="更新于 2019-06-03 00:00:00">2019-06-03</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/React/">React</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">5.4k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>24分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="Ant Design 组件使用随笔"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h1 id="Ant-Design-组件使用随笔"><a href="#Ant-Design-组件使用随笔" class="headerlink" title="Ant Design 组件使用随笔"></a>Ant Design 组件使用随笔</h1><h2 id="后台管理的路由"><a href="#后台管理的路由" class="headerlink" title="后台管理的路由"></a>后台管理的路由</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>我们在vue的时候 登录 和 首页 公用的是一个 router-view 然后首页里面还有一个router-view 是放置二级路由的</span><br><span class="line"><span class="number">2.</span>而在react中我们是没有 router-view 这个组件的 只能通过拿到路由表 通过遍历去 渲染所有Route标签 然后通过路由访问去 决定 显示哪个Route 标签 </span><br></pre></td></tr></table></figure>
<h3 id="index-jsx-文件"><a href="#index-jsx-文件" class="headerlink" title="index.jsx 文件"></a>index.jsx 文件</h3><figure class="highlight jsx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// react 路由表 routes 文件夹下 index.js文件</span></span><br><span class="line"><span class="comment">//这里我们要写我们的路由配置文件 主要不需要验证(登录)就可以访问的页面 比如 登录 404等 还有需要登录才可以访问的页面</span></span><br><span class="line"><span class="keyword">import</span> Login <span class="keyword">from</span> <span class="string">&quot;../pages/Login&quot;</span>;</span><br><span class="line"><span class="keyword">import</span> Index <span class="keyword">from</span> <span class="string">&quot;../pages/admin/dashboard/Index&quot;</span>;</span><br><span class="line"><span class="keyword">import</span> List <span class="keyword">from</span> <span class="string">&quot;../pages/admin/products/List&quot;</span>;</span><br><span class="line"><span class="keyword">import</span> Edit <span class="keyword">from</span> <span class="string">&quot;../pages/admin/products/Edit&quot;</span>;</span><br><span class="line"><span class="keyword">import</span> PageNotFound <span class="keyword">from</span> <span class="string">&quot;../pages/PageNotFound&quot;</span>;</span><br><span class="line"><span class="comment">//写入配置文件  mainRoutes 是不需要 登录就可以访问的页面</span></span><br><span class="line"><span class="keyword">export</span> <span class="keyword">const</span> mainRoutes = [</span><br><span class="line">    &#123;<span class="attr">path</span>:<span class="string">&#x27;/login&#x27;</span>,<span class="attr">component</span>:Login&#125;,</span><br><span class="line">    &#123;<span class="attr">path</span>:<span class="string">&#x27;/404&#x27;</span>,<span class="attr">component</span>:PageNotFound&#125;</span><br><span class="line">]</span><br><span class="line"><span class="comment">//adminRoute是需要登录才可以访问的页面</span></span><br><span class="line"><span class="keyword">export</span> <span class="keyword">const</span> adminRoutes = [</span><br><span class="line">    &#123;<span class="attr">path</span>:<span class="string">&#x27;/admin/dashboard&#x27;</span>,<span class="attr">component</span>:Index,<span class="attr">isShow</span>:<span class="literal">true</span>,<span class="attr">title</span>:<span class="string">&#x27;看板&#x27;</span>&#125;,</span><br><span class="line">    <span class="comment">//这里我们的路由路径 都又相同的路路径 所以我们配置以下exact精准匹配</span></span><br><span class="line">    &#123;<span class="attr">path</span>:<span class="string">&#x27;/admin/products&#x27;</span>,<span class="attr">component</span>:List,<span class="attr">exact</span>:<span class="literal">true</span>,<span class="attr">isShow</span>:<span class="literal">true</span>,<span class="attr">title</span>:<span class="string">&#x27;商品管理&#x27;</span>&#125;,</span><br><span class="line">    &#123;<span class="attr">path</span>:<span class="string">&#x27;/admin/products/edit/:id?&#x27;</span>,<span class="attr">exact</span>:<span class="literal">false</span>, <span class="attr">component</span>:Edit,<span class="attr">isShow</span>:<span class="literal">false</span>,<span class="attr">title</span>:<span class="string">&#x27;编辑&#x27;</span>&#125;</span><br><span class="line">]</span><br><span class="line"><span class="comment">//isShow 我们需要根据路由表配置菜单  而这个菜单是否显示 就用isShow去判断</span></span><br></pre></td></tr></table></figure>
<figure class="highlight jsx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 以上我们配置好了路由表 就需要在启动文件 也就是index.jsx里拿到我们的路由文件 去渲染 </span></span><br><span class="line"><span class="comment">//这里需要注意 我们的登录页面的显示  和 首页的显示 一共是分为两个文件 index.jsx主要是用来访问 登录页面 和我们的404  而app.jsx 文件  主要是放置了我们的一个布局页面 然后 通过遍历的方式把这些显示出来 使用类似插槽的方式在插入到我们的布局页面中</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> React <span class="keyword">from</span> <span class="string">&#x27;react&#x27;</span>;</span><br><span class="line"><span class="keyword">import</span> ReactDOM <span class="keyword">from</span> <span class="string">&#x27;react-dom&#x27;</span>;</span><br><span class="line"><span class="keyword">import</span> <span class="string">&#x27;./index.css&#x27;</span>;</span><br><span class="line"><span class="keyword">import</span> <span class="string">&#x27;antd/dist/antd.css&#x27;</span></span><br><span class="line"><span class="keyword">import</span> <span class="string">&#x27;./mock/index.js&#x27;</span></span><br><span class="line"><span class="keyword">import</span> &#123;mainRoutes&#125; <span class="keyword">from</span> <span class="string">&#x27;./routes&#x27;</span></span><br><span class="line"><span class="keyword">import</span> App <span class="keyword">from</span> <span class="string">&#x27;./App&#x27;</span></span><br><span class="line"><span class="keyword">import</span> reportWebVitals <span class="keyword">from</span> <span class="string">&#x27;./reportWebVitals&#x27;</span>;</span><br><span class="line"><span class="keyword">import</span> &#123;HashRouter <span class="keyword">as</span> Router, Switch,Route,Redirect&#125; <span class="keyword">from</span> <span class="string">&#x27;react-router-dom&#x27;</span></span><br><span class="line">ReactDOM.render(</span><br><span class="line">  &lt;Router&gt;</span><br><span class="line">    &lt;Switch&gt;</span><br><span class="line">      &#123;<span class="comment">/* 这里就是 当我们访问以/admin 开头的时候 都走我们的App组件 然后我们配置的 adminRoutes都在App组件里配置 */</span>&#125;</span><br><span class="line">      &#123;<span class="comment">/* render=&#123;(props) =&gt; &lt;App &#123;...props&#125;/&gt;&#125;  props 就是把我们的路由属性也传给我们的App组件 */</span>&#125;</span><br><span class="line">      &lt;Route path=<span class="string">&quot;/admin&quot;</span> render=&#123;<span class="function">(<span class="params">props</span>) =&gt;</span> <span class="xml"><span class="tag">&lt;<span class="name">App</span> &#123;<span class="attr">...props</span>&#125;/&gt;</span></span>&#125; /&gt;</span><br><span class="line">      &#123;mainRoutes.map(<span class="function"><span class="params">route</span> =&gt;</span> &#123;</span><br><span class="line">        <span class="keyword">return</span> <span class="xml"><span class="tag">&lt;<span class="name">Route</span> <span class="attr">key</span>=<span class="string">&#123;route.path&#125;</span> &#123;<span class="attr">...route</span>&#125; /&gt;</span></span></span><br><span class="line">      &#125;)&#125;</span><br><span class="line">      &#123;<span class="comment">/* 这里就是当我们从/来的时候 先让让去admin 然后我们在APP.js里在设置当你是从/来的时候我就让你去路由的看板页面 */</span>&#125;</span><br><span class="line">      &lt;Redirect to=<span class="string">&quot;/admin&quot;</span> <span class="keyword">from</span>=<span class="string">&quot;/&quot;</span> &gt;&lt;/Redirect&gt;</span><br><span class="line">      &#123;<span class="comment">/* 这里的Redirect用法就是 当我们访问上面没有的路径的时候 就走到404页面 */</span>&#125;</span><br><span class="line">      &lt;Redirect to=<span class="string">&quot;/404&quot;</span>&gt;&lt;/Redirect&gt;</span><br><span class="line">    &lt;/Switch&gt;</span><br><span class="line">  &lt;/Router&gt;</span><br><span class="line">  ,</span><br><span class="line">  <span class="built_in">document</span>.getElementById(<span class="string">&#x27;root&#x27;</span>)</span><br><span class="line">);</span><br></pre></td></tr></table></figure>
<h3 id="App-jsx-文件"><a href="#App-jsx-文件" class="headerlink" title="App.jsx 文件"></a>App.jsx 文件</h3><figure class="highlight jsx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>app.jsx文件 主要是我们的首页  通过刚刚上面的路由重定向逻辑 我们知道 只要是从 <span class="string">&#x27;/&#x27;</span> 来的都让他去 <span class="string">&#x27;/admin&#x27;</span> 的路由去渲染的组件 而 <span class="string">&#x27;/admin&#x27;</span> 又去渲染了我们的App.jsx 文件 </span><br><span class="line"><span class="number">2.</span>App.jsx文件 主要是两个组成部分 第一个是 你的布局文件 Frame 这里主要是由header 和 sidebar 右侧需要渲染的内容 </span><br><span class="line"><span class="number">3.</span>第二个就是 你的组件 就是 右侧渲染内容 渲染的组件 我们通过类似插槽的形式 把这些需要渲染的组件 插入到我们的Frame组件中去 </span><br><span class="line"><span class="number">4.</span>在这里 我们还需要 判断 有没有登录 如果有登录的时候 我才去渲染我们的主页 如果没有 我就 让你去登陆页面</span><br></pre></td></tr></table></figure>
<figure class="highlight jsx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//APP.jsx</span></span><br><span class="line"><span class="keyword">import</span> React <span class="keyword">from</span> <span class="string">&#x27;react&#x27;</span></span><br><span class="line"><span class="keyword">import</span> &#123; Route,Redirect,Switch&#125; <span class="keyword">from</span> <span class="string">&#x27;react-router-dom&#x27;</span></span><br><span class="line"><span class="keyword">import</span> &#123;adminRoutes&#125; <span class="keyword">from</span> <span class="string">&#x27;./routes&#x27;</span></span><br><span class="line"><span class="keyword">import</span> &#123;isLogin&#125; <span class="keyword">from</span> <span class="string">&#x27;@/utils/auth&#x27;</span></span><br><span class="line"><span class="comment">//这里的Frame组件  就是我们的整个头部菜单 导航的组件 然乎右侧显示的内容 使用类似插槽的方式插入了进去</span></span><br><span class="line"><span class="keyword">import</span> Frame <span class="keyword">from</span> <span class="string">&#x27;./components/Frame/Index&#x27;</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">App</span>(<span class="params"></span>) </span>&#123;</span><br><span class="line">  <span class="keyword">return</span> (</span><br><span class="line">    isLogin()?</span><br><span class="line">    &lt;Frame&gt;</span><br><span class="line">      &lt;Switch&gt;</span><br><span class="line">        &#123;<span class="comment">/* 循环我们需要通过登录才可以访问页面 首先当我们都用/admin开头的路径 他走的就是我们的这个APP组件</span></span><br><span class="line"><span class="comment">        然后我们在这个APP组件里 又循环了 我们必须要登录才能访问的页面 然后通过不同的路径再去访问我们不同的页面 */</span>&#125;</span><br><span class="line">        &#123;adminRoutes.map(<span class="function"><span class="params">route</span> =&gt;</span> &#123;</span><br><span class="line">          <span class="keyword">return</span> <span class="xml"><span class="tag">&lt;<span class="name">Route</span> </span></span></span><br><span class="line"><span class="xml">          key=&#123;route.path&#125; </span></span><br><span class="line"><span class="xml">          path=&#123;route.path&#125; </span></span><br><span class="line"><span class="xml">          exact=&#123;route.exact&#125; </span></span><br><span class="line"><span class="xml">          render=&#123; routeProps =&gt; &#123;</span></span><br><span class="line"><span class="xml">            return &lt; route.component &#123;...routeProps&#125;/&gt;</span></span><br><span class="line">          &#125; &#125;/&gt;</span><br><span class="line">        &#125;)&#125;</span><br><span class="line">        &#123;<span class="comment">/* 如果以上都没有的话 就去404页面 */</span>&#125;</span><br><span class="line">        &lt;Redirect to=&#123;adminRoutes[<span class="number">0</span>].path&#125; <span class="keyword">from</span>=<span class="string">&#x27;/admin&#x27;</span>&gt;&lt;/Redirect&gt;</span><br><span class="line">        &lt;Redirect to=<span class="string">&quot;/404&quot;</span>&gt;&lt;/Redirect&gt;</span><br><span class="line">      &lt;/Switch&gt;</span><br><span class="line">    &lt;/Frame&gt;</span><br><span class="line">    :</span><br><span class="line">    &lt;Redirect to=<span class="string">&quot;/login&quot;</span>&gt;&lt;/Redirect&gt;</span><br><span class="line">  );</span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">export</span> <span class="keyword">default</span> App;</span><br></pre></td></tr></table></figure>
<h3 id="Frame-jsx"><a href="#Frame-jsx" class="headerlink" title="Frame.jsx"></a>Frame.jsx</h3><figure class="highlight jsx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>主要用来布局 有header sidebar </span><br><span class="line"><span class="number">2.</span> 其中content 可以里放置 我们在上面 的App.jsx里插入到 Frame 里的需要渲染的组件</span><br><span class="line"><span class="number">3.</span> 通过<span class="built_in">this</span>.props.children 可以拿到 我们插入进来的 组件 </span><br></pre></td></tr></table></figure>
<figure class="highlight jsx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> React, &#123; Component &#125; <span class="keyword">from</span> <span class="string">&#x27;react&#x27;</span></span><br><span class="line"><span class="keyword">import</span> &#123; Layout, Menu, Breadcrumb &#125; <span class="keyword">from</span> <span class="string">&#x27;antd&#x27;</span>;</span><br><span class="line"><span class="keyword">import</span> &#123; UserOutlined, LaptopOutlined, NotificationOutlined &#125; <span class="keyword">from</span> <span class="string">&#x27;@ant-design/icons&#x27;</span>;</span><br><span class="line"><span class="keyword">import</span> &#123;withRouter &#125; <span class="keyword">from</span> <span class="string">&#x27;react-router-dom&#x27;</span></span><br><span class="line"><span class="keyword">import</span> &#123;adminRoutes &#125; <span class="keyword">from</span> <span class="string">&#x27;../../routes&#x27;</span></span><br><span class="line"><span class="comment">//这里就是先过滤了一下 哪些是需要在菜单栏里面显示的菜单</span></span><br><span class="line"><span class="keyword">const</span> routes = adminRoutes.filter( <span class="function"><span class="params">item</span> =&gt;</span> item.isShow)</span><br><span class="line"><span class="keyword">const</span> &#123; Header, Content, Sider &#125; = Layout;</span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">Index</span> <span class="keyword">extends</span> <span class="title">Component</span> </span>&#123;</span><br><span class="line">    <span class="function"><span class="title">componentDidMount</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="function"><span class="title">render</span>(<span class="params"></span>)</span> &#123;</span><br><span class="line">        <span class="keyword">return</span> (</span><br><span class="line">            &lt;Layout&gt;</span><br><span class="line">            &lt;Header className=<span class="string">&quot;header&quot;</span>&gt;</span><br><span class="line">            &lt;div className=<span class="string">&quot;logo&quot;</span> style=&#123;&#123;<span class="attr">color</span>:<span class="string">&#x27;#fff&#x27;</span>&#125;&#125;&gt;我是logo&lt;/div&gt;</span><br><span class="line">            &lt;/Header&gt;</span><br><span class="line">            &lt;Layout&gt;</span><br><span class="line">            &lt;Sider width=&#123;<span class="number">200</span>&#125; className=<span class="string">&quot;site-layout-background&quot;</span>&gt;</span><br><span class="line">                &lt;Menu</span><br><span class="line">                mode=<span class="string">&quot;inline&quot;</span></span><br><span class="line">                <span class="comment">//用来控制 是否选中 </span></span><br><span class="line">                defaultSelectedKeys=&#123;[<span class="built_in">this</span>.props.location.pathname]&#125;</span><br><span class="line">                defaultOpenKeys=&#123;[<span class="string">&#x27;sub1&#x27;</span>]&#125;</span><br><span class="line">                <span class="comment">// selectedKeys=&#123;[this.props.match.path]&#125;</span></span><br><span class="line">                style=&#123;&#123; <span class="attr">height</span>: <span class="string">&#x27;100%&#x27;</span>, <span class="attr">borderRight</span>: <span class="number">0</span> &#125;&#125;</span><br><span class="line">                &gt;</span><br><span class="line">                    &#123;<span class="comment">/* 遍历我们的路由生成菜单 及其点击的时候 右侧的内容跳转到对应的路由文件 */</span>&#125;</span><br><span class="line">                    &#123;routes.map(<span class="function"><span class="params">item</span> =&gt;</span> &#123;</span><br><span class="line">                        <span class="keyword">return</span>(</span><br><span class="line">                            &lt;Menu.Item key=&#123;item.path&#125; onClick=&#123;<span class="function">() =&gt;</span> &#123;<span class="built_in">this</span>.props.history.push(<span class="string">`<span class="subst">$&#123;item.path&#125;</span>`</span>)&#125;&#125;&gt;&#123;item.title&#125;&lt;/Menu.Item&gt;</span><br><span class="line">                        )</span><br><span class="line">                    &#125;)&#125;</span><br><span class="line">                &lt;/Menu&gt;</span><br><span class="line">            &lt;/Sider&gt;</span><br><span class="line">            &lt;Layout style=&#123;&#123; <span class="attr">padding</span>: <span class="string">&#x27;0 24px 24px&#x27;</span> &#125;&#125;&gt;</span><br><span class="line">                &lt;Breadcrumb style=&#123;&#123; <span class="attr">margin</span>: <span class="string">&#x27;16px 0&#x27;</span> &#125;&#125;&gt;</span><br><span class="line">                &lt;Breadcrumb.Item&gt;Home&lt;/Breadcrumb.Item&gt;</span><br><span class="line">                &lt;Breadcrumb.Item&gt;List&lt;/Breadcrumb.Item&gt;</span><br><span class="line">                &lt;Breadcrumb.Item&gt;App&lt;/Breadcrumb.Item&gt;</span><br><span class="line">                &lt;/Breadcrumb&gt;</span><br><span class="line">                &lt;Content</span><br><span class="line">                className=<span class="string">&quot;site-layout-background&quot;</span></span><br><span class="line">                style=&#123;&#123;</span><br><span class="line">                    padding: <span class="number">24</span>,</span><br><span class="line">                    margin: <span class="number">0</span>,</span><br><span class="line">                    minHeight: <span class="number">280</span>,</span><br><span class="line">                &#125;&#125;</span><br><span class="line">                &gt;</span><br><span class="line">                &#123;<span class="comment">/* 这里就是就是我们上面对应的路由组件 插入了进来 */</span>&#125;</span><br><span class="line">                &#123;<span class="built_in">this</span>.props.children&#125;</span><br><span class="line">                &lt;/Content&gt;</span><br><span class="line">            &lt;/Layout&gt;</span><br><span class="line">            &lt;/Layout&gt;</span><br><span class="line">        &lt;/Layout&gt;</span><br><span class="line">        )</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">//这里为了让我们的菜单有具备编程式导航的功能 组要用我们的路由组件包裹一下</span></span><br><span class="line"><span class="keyword">export</span> <span class="keyword">default</span> withRouter(Index)</span><br></pre></td></tr></table></figure>
<h2 id="列表页"><a href="#列表页" class="headerlink" title="列表页"></a>列表页</h2><figure class="highlight jsx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>主要是通过andt 的 &lt;Table&gt; 标签 去渲染的</span><br><span class="line"><span class="number">2.</span>表格的配置 数据的渲染 分页的显示 表头的拖拽</span><br><span class="line"><span class="number">3.</span>动作按钮 比如删除 编辑 等 当前行的数据</span><br></pre></td></tr></table></figure>
<h3 id="配置"><a href="#配置" class="headerlink" title="配置"></a>配置</h3><figure class="highlight jsx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>andt的Table 组件 通过 columns 关键字 来指定你需要渲染的内容 也就是表头的显示 比如里的序号 每一列的内容等</span><br><span class="line"><span class="number">2.</span>dataSource 关键字 主要用来渲染表格的内容 比如你后台返回来的数据</span><br><span class="line"><span class="number">3.</span>默认我们需要在 &lt;Table /&gt; 标签上给定一个key 指定的数据的唯一值 否则会报错</span><br><span class="line"><span class="number">4.</span>在columns 的每一项里 我们还可以配置每一列的宽度 文字对齐方式 等一些列动作 具体参照官方文档</span><br></pre></td></tr></table></figure>
<figure class="highlight jsx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//用来指定需要渲染的数据</span></span><br><span class="line"><span class="keyword">const</span> dataSource = [</span><br><span class="line">  &#123;</span><br><span class="line">    key: <span class="string">&#x27;1&#x27;</span>,</span><br><span class="line">    name: <span class="string">&#x27;胡彦斌&#x27;</span>,</span><br><span class="line">    age: <span class="number">32</span>,</span><br><span class="line">    address: <span class="string">&#x27;西湖区湖底公园1号&#x27;</span>,</span><br><span class="line">  &#125;,</span><br><span class="line">  &#123;</span><br><span class="line">    key: <span class="string">&#x27;2&#x27;</span>,</span><br><span class="line">    name: <span class="string">&#x27;胡彦祖&#x27;</span>,</span><br><span class="line">    age: <span class="number">42</span>,</span><br><span class="line">    address: <span class="string">&#x27;西湖区湖底公园1号&#x27;</span>,</span><br><span class="line">  &#125;,</span><br><span class="line">];</span><br><span class="line"><span class="comment">//用来指定要渲染的内容 比如表头</span></span><br><span class="line"><span class="keyword">const</span> columns = [</span><br><span class="line">  &#123;</span><br><span class="line">    title: <span class="string">&#x27;姓名&#x27;</span>,</span><br><span class="line">    <span class="comment">//表格需要渲染数据的字段 和我们的elementUI中的prop 一样</span></span><br><span class="line">    dataIndex: <span class="string">&#x27;name&#x27;</span>,</span><br><span class="line">    key: <span class="string">&#x27;name&#x27;</span>,</span><br><span class="line">  &#125;,</span><br><span class="line">  &#123;</span><br><span class="line">    title: <span class="string">&#x27;年龄&#x27;</span>,</span><br><span class="line">    dataIndex: <span class="string">&#x27;age&#x27;</span>,</span><br><span class="line">    key: <span class="string">&#x27;age&#x27;</span>,</span><br><span class="line">  &#125;,</span><br><span class="line">  &#123;</span><br><span class="line">    title: <span class="string">&#x27;住址&#x27;</span>,</span><br><span class="line">    dataIndex: <span class="string">&#x27;address&#x27;</span>,</span><br><span class="line">    key: <span class="string">&#x27;address&#x27;</span>,</span><br><span class="line">  &#125;,</span><br><span class="line">];</span><br><span class="line"><span class="comment">//通过 jsx语法绑定到你的Table组件</span></span><br><span class="line">&lt;Table dataSource=&#123;dataSource&#125; columns=&#123;columns&#125; /&gt;;</span><br></pre></td></tr></table></figure>
<p><img src="E:\笔记\Ant Design\1.png" alt=""></p>
<h3 id="动作按钮"><a href="#动作按钮" class="headerlink" title="动作按钮"></a>动作按钮</h3><figure class="highlight jsx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>在elementUi里 我们的的东走按钮 比如删除 编辑等 是通过作用域插槽 插入进去的</span><br><span class="line"><span class="number">2.</span>而在 ant里 我们需要通过 columns的 render函数 直接把我们的动作按钮渲染到 我们的表格对应的列中</span><br><span class="line"><span class="number">3.</span> 这个render函数的 会有参数 对应就是我们当前列的值 当前行的数据 索引等</span><br></pre></td></tr></table></figure>
<p><img src="E:\笔记\Ant Design\2.png" alt=""></p>
<figure class="highlight jsx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> React, &#123; Component &#125; <span class="keyword">from</span> <span class="string">&#x27;react&#x27;</span></span><br><span class="line"><span class="keyword">import</span> &#123; Table, Tag, Space &#125; <span class="keyword">from</span> <span class="string">&#x27;antd&#x27;</span>;</span><br><span class="line"><span class="keyword">const</span> columns = [</span><br><span class="line">    &#123;</span><br><span class="line">      title: <span class="string">&#x27;Name&#x27;</span>,</span><br><span class="line">      dataIndex: <span class="string">&#x27;name&#x27;</span>,</span><br><span class="line">      key: <span class="string">&#x27;name&#x27;</span>,</span><br><span class="line">      render: <span class="function"><span class="params">text</span> =&gt;</span> <span class="xml"><span class="tag">&lt;<span class="name">a</span>&gt;</span>&#123;text&#125;<span class="tag">&lt;/<span class="name">a</span>&gt;</span></span>,</span><br><span class="line">    &#125;,</span><br><span class="line">    &#123;</span><br><span class="line">      title: <span class="string">&#x27;Age&#x27;</span>,</span><br><span class="line">      dataIndex: <span class="string">&#x27;age&#x27;</span>,</span><br><span class="line">      key: <span class="string">&#x27;age&#x27;</span>,</span><br><span class="line">    &#125;,</span><br><span class="line">    &#123;</span><br><span class="line">      title: <span class="string">&#x27;Address&#x27;</span>,</span><br><span class="line">      dataIndex: <span class="string">&#x27;address&#x27;</span>,</span><br><span class="line">      key: <span class="string">&#x27;address&#x27;</span>,</span><br><span class="line">    &#125;,</span><br><span class="line">    &#123;</span><br><span class="line">      title: <span class="string">&#x27;Tags&#x27;</span>,</span><br><span class="line">      key: <span class="string">&#x27;tags&#x27;</span>,</span><br><span class="line">      dataIndex: <span class="string">&#x27;tags&#x27;</span>,</span><br><span class="line">      render: <span class="function"><span class="params">tags</span> =&gt;</span> (</span><br><span class="line">      <span class="comment">//我们可以在render函数里面做判断     </span></span><br><span class="line">        &lt;&gt;</span><br><span class="line">          &#123;tags.map(<span class="function"><span class="params">tag</span> =&gt;</span> &#123;</span><br><span class="line">              <span class="built_in">console</span>.log(tag)</span><br><span class="line">            <span class="keyword">let</span> color = tag.length &gt; <span class="number">5</span> ? <span class="string">&#x27;geekblue&#x27;</span> : <span class="string">&#x27;green&#x27;</span>;</span><br><span class="line">            <span class="keyword">if</span> (tag === <span class="string">&#x27;loser&#x27;</span>) &#123;</span><br><span class="line">              color = <span class="string">&#x27;volcano&#x27;</span>;</span><br><span class="line">            &#125;</span><br><span class="line">            <span class="keyword">return</span> (</span><br><span class="line">              &lt;Tag color=&#123;color&#125; key=&#123;tag&#125;&gt;</span><br><span class="line">                &#123;tag.toUpperCase()&#125;</span><br><span class="line">              &lt;/Tag&gt;</span><br><span class="line">            );</span><br><span class="line">          &#125;)&#125;</span><br><span class="line">        &lt;/&gt;</span><br><span class="line">      ),</span><br><span class="line">    &#125;,</span><br><span class="line">    &#123;</span><br><span class="line">      title: <span class="string">&#x27;Action&#x27;</span>,</span><br><span class="line">      key: <span class="string">&#x27;action&#x27;</span>,</span><br><span class="line">      render: <span class="function">(<span class="params">text, record</span>) =&gt;</span> (</span><br><span class="line">        &lt;Space size=<span class="string">&quot;middle&quot;</span>&gt;</span><br><span class="line">          &lt;a&gt;Invite &#123;record.name&#125;&lt;/a&gt;</span><br><span class="line">          &lt;a&gt;Delete&lt;/a&gt;</span><br><span class="line">        &lt;/Space&gt;</span><br><span class="line">      ),</span><br><span class="line">    &#125;,</span><br><span class="line">  ];</span><br><span class="line">  </span><br><span class="line">  <span class="keyword">const</span> data = [</span><br><span class="line">    &#123;</span><br><span class="line">      key: <span class="string">&#x27;1&#x27;</span>,</span><br><span class="line">      name: <span class="string">&#x27;John Brown&#x27;</span>,</span><br><span class="line">      age: <span class="number">32</span>,</span><br><span class="line">      address: <span class="string">&#x27;New York No. 1 Lake Park&#x27;</span>,</span><br><span class="line">      tags: [<span class="string">&#x27;nice&#x27;</span>, <span class="string">&#x27;developer&#x27;</span>],</span><br><span class="line">    &#125;,</span><br><span class="line">    &#123;</span><br><span class="line">      key: <span class="string">&#x27;2&#x27;</span>,</span><br><span class="line">      name: <span class="string">&#x27;Jim Green&#x27;</span>,</span><br><span class="line">      age: <span class="number">42</span>,</span><br><span class="line">      address: <span class="string">&#x27;London No. 1 Lake Park&#x27;</span>,</span><br><span class="line">      tags: [<span class="string">&#x27;loser&#x27;</span>],</span><br><span class="line">    &#125;,</span><br><span class="line">    &#123;</span><br><span class="line">      key: <span class="string">&#x27;3&#x27;</span>,</span><br><span class="line">      name: <span class="string">&#x27;Joe Black&#x27;</span>,</span><br><span class="line">      age: <span class="number">32</span>,</span><br><span class="line">      address: <span class="string">&#x27;Sidney No. 1 Lake Park&#x27;</span>,</span><br><span class="line">      tags: [<span class="string">&#x27;cool&#x27;</span>, <span class="string">&#x27;teacher&#x27;</span>],</span><br><span class="line">    &#125;,</span><br><span class="line">  ];</span><br><span class="line"><span class="keyword">export</span> <span class="keyword">default</span> <span class="class"><span class="keyword">class</span> <span class="title">Test</span> <span class="keyword">extends</span> <span class="title">Component</span> </span>&#123;</span><br><span class="line">    <span class="function"><span class="title">render</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">        <span class="keyword">return</span> <span class="xml"><span class="tag">&lt;<span class="name">Table</span> <span class="attr">columns</span>=<span class="string">&#123;columns&#125;</span> <span class="attr">dataSource</span>=<span class="string">&#123;data&#125;</span> /&gt;</span></span></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h3 id="分页"><a href="#分页" class="headerlink" title="分页"></a>分页</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>在ant 里 分页可以单独拿出来一个组件 也可以在表格上使用配置项的方式去显示</span><br></pre></td></tr></table></figure>
<figure class="highlight jsx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//通过 pagination来指定 分页 position分页按钮的 位置 size 分页组件的大小 total的总数 defaultPageSize 一页显示多少条 加了这个选项 分页才会有效果 onChange当改变分页的时候触发的回到 参数是当前页码 具体的其他API查看分页组件</span></span><br><span class="line">&lt;Table pagination=&#123;&#123;<span class="attr">position</span>:[<span class="string">&#x27;bottomRight&#x27;</span>],<span class="attr">size</span>:<span class="string">&#x27;small&#x27;</span>,<span class="attr">total</span>:<span class="built_in">this</span>.state.pageTotle,<span class="attr">defaultPageSize</span>: <span class="built_in">this</span>.state.page.pageSize,<span class="attr">onChange</span>:<span class="built_in">this</span>.pageonChange&#125;&#125; rowKey=<span class="string">&#x27;id&#x27;</span> bordered components=&#123;<span class="built_in">this</span>.components&#125; columns=&#123;columns&#125; dataSource=&#123;<span class="built_in">this</span>.state.data&#125; /&gt; </span><br></pre></td></tr></table></figure>
<h3 id="表头的拖拽"><a href="#表头的拖拽" class="headerlink" title="表头的拖拽"></a>表头的拖拽</h3><figure class="highlight jsx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>这里 如果想要拖拽表头 就要 指定 columns 每一页的宽度</span><br><span class="line"><span class="number">2.</span>需要引入比的组件 然后来配置</span><br></pre></td></tr></table></figure>
<figure class="highlight jsx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> React, &#123; Component &#125; <span class="keyword">from</span> <span class="string">&#x27;react&#x27;</span></span><br><span class="line"><span class="keyword">import</span> &#123; Card , Table,Button,Pagination,Popconfirm&#125; <span class="keyword">from</span> <span class="string">&#x27;antd&#x27;</span></span><br><span class="line"><span class="keyword">import</span> &#123; Radio &#125; <span class="keyword">from</span> <span class="string">&#x27;antd&#x27;</span> </span><br><span class="line"><span class="keyword">import</span> &#123; Resizable &#125; <span class="keyword">from</span> <span class="string">&#x27;react-resizable&#x27;</span></span><br><span class="line"><span class="keyword">import</span> &#123;getTable,delItem&#125; <span class="keyword">from</span> <span class="string">&#x27;@/api/table&#x27;</span></span><br><span class="line"></span><br><span class="line"><span class="comment">//1.需要重新包装一下我们的 Resizable 组件</span></span><br><span class="line"><span class="keyword">const</span> ResizableTitle = <span class="function"><span class="params">props</span> =&gt;</span> &#123;</span><br><span class="line">  <span class="keyword">const</span> &#123; onResize, width, ...restProps &#125; = props </span><br><span class="line"></span><br><span class="line">  <span class="keyword">if</span> (!width) &#123;</span><br><span class="line">    <span class="keyword">return</span> <span class="xml"><span class="tag">&lt;<span class="name">th</span> &#123;<span class="attr">...restProps</span>&#125; /&gt;</span></span> </span><br><span class="line">  &#125;</span><br><span class="line"></span><br><span class="line">  <span class="keyword">return</span> (</span><br><span class="line">    &lt;Resizable</span><br><span class="line">      width=&#123;width&#125;</span><br><span class="line">      height=&#123;<span class="number">0</span>&#125;</span><br><span class="line">      handle=&#123;</span><br><span class="line">        &lt;span</span><br><span class="line">          className=<span class="string">&quot;react-resizable-handle&quot;</span></span><br><span class="line">          onClick=&#123;<span class="function"><span class="params">e</span> =&gt;</span> &#123;</span><br><span class="line">            e.stopPropagation() </span><br><span class="line">          &#125;&#125;</span><br><span class="line">        /&gt;</span><br><span class="line">      &#125;</span><br><span class="line">      onResize=&#123;onResize&#125;</span><br><span class="line">      draggableOpts=&#123;&#123; <span class="attr">enableUserSelectHack</span>: <span class="literal">false</span> &#125;&#125;</span><br><span class="line">    &gt;</span><br><span class="line">      &lt;th &#123;...restProps&#125; /&gt;</span><br><span class="line">    &lt;/Resizable&gt;</span><br><span class="line">  )</span><br><span class="line">&#125; </span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">List</span> <span class="keyword">extends</span> <span class="title">React</span>.<span class="title">Component</span> </span>&#123;</span><br><span class="line">  <span class="comment">//用来把   Resizable 组件注入到我们的表格中去 </span></span><br><span class="line">  components = &#123;</span><br><span class="line">    header: &#123;</span><br><span class="line">      cell: ResizableTitle,</span><br><span class="line">    &#125;,</span><br><span class="line">  &#125; </span><br><span class="line">  <span class="comment">//3.当我们拖拽的时候改变宽度时 需要使用这个函数 来重新计算我们的宽度	</span></span><br><span class="line">  handleResize = <span class="function"><span class="params">index</span> =&gt;</span> <span class="function">(<span class="params">e, &#123; size &#125;</span>) =&gt;</span> &#123;</span><br><span class="line">    <span class="built_in">this</span>.setState(<span class="function">(<span class="params">&#123; columns &#125;</span>) =&gt;</span> &#123;</span><br><span class="line">      <span class="keyword">const</span> nextColumns = [...columns] </span><br><span class="line">      nextColumns[index] = &#123;</span><br><span class="line">        ...nextColumns[index],</span><br><span class="line">        width: size.width,</span><br><span class="line">      &#125; </span><br><span class="line">      <span class="keyword">return</span> &#123; <span class="attr">columns</span>: nextColumns &#125; </span><br><span class="line">    &#125;) </span><br><span class="line">  &#125; </span><br><span class="line">  <span class="function"><span class="title">render</span>(<span class="params"></span>)</span> &#123;</span><br><span class="line">    <span class="comment">//4.最后需要 把我们的表格项 重新 写一下   </span></span><br><span class="line">    <span class="keyword">const</span> columns = <span class="built_in">this</span>.state.columns.map(<span class="function">(<span class="params">col, index</span>) =&gt;</span> (&#123;</span><br><span class="line">      ...col,</span><br><span class="line">      onHeaderCell: <span class="function"><span class="params">column</span> =&gt;</span> (&#123;</span><br><span class="line">        width: column.width,</span><br><span class="line">        onResize: <span class="built_in">this</span>.handleResize(index),</span><br><span class="line">      &#125;),</span><br><span class="line">    &#125;)) </span><br><span class="line"></span><br><span class="line">    <span class="keyword">return</span> <span class="xml">&lt;Card</span></span><br><span class="line"><span class="xml">    <span class="tag">&lt;<span class="name">Table</span> <span class="attr">rowKey</span>=<span class="string">&#x27;id&#x27;</span> <span class="attr">bordered</span> <span class="attr">components</span>=<span class="string">&#123;this.components&#125;</span> <span class="attr">columns</span>=<span class="string">&#123;columns&#125;</span> <span class="attr">dataSource</span>=<span class="string">&#123;data&#125;</span> /&gt;</span> </span></span><br><span class="line"><span class="xml">    <span class="tag">&lt;/<span class="name">Card</span>&gt;</span></span></span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">export</span> <span class="keyword">default</span> List</span><br></pre></td></tr></table></figure>
<h2 id="表单页"><a href="#表单页" class="headerlink" title="表单页"></a>表单页</h2><figure class="highlight jsx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>表单的配置 比如 行的显示 宽度 尺寸</span><br><span class="line"><span class="number">2.</span>表单的验证 验证时机 自定义验证</span><br><span class="line"><span class="number">3.</span>表单的取值 和 赋值 这里 主要是 函数式组件 和 类组件 </span><br></pre></td></tr></table></figure>
<h3 id="表单的配置"><a href="#表单的配置" class="headerlink" title="表单的配置"></a>表单的配置</h3><figure class="highlight jsx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>labelCol 主要有两个选项 span 用来控制 label项所占的分数  offset 用来控制向左边的偏移量</span><br><span class="line"><span class="number">2.</span>wrapperCol 主要有两个选项  span 用来控制 label所对应的 内容区域的 所占的分数 offset 用来控制向左的便宜量</span><br></pre></td></tr></table></figure>
<p><img src="E:\笔记\Ant Design\3.png" alt=""></p>
<h3 id="表单的验证"><a href="#表单的验证" class="headerlink" title="表单的验证"></a>表单的验证</h3><figure class="highlight jsx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>我们可以在Form.Item 上通过 rules 属性 配置 表单的验证 </span><br><span class="line"><span class="number">2.</span>也可以在 rules 里增加 &#123;<span class="attr">validator</span>:<span class="built_in">this</span>.validUsername&#125; 来写自定义校验</span><br><span class="line"><span class="number">3.</span>表单的验证时机 我们可以在 Form.Item 里添加 validateTrigger=<span class="string">&quot;onBlur&quot;</span> 来改变校验的触发时机</span><br></pre></td></tr></table></figure>
<figure class="highlight jsx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> &#123; Form, Input, Button, Checkbox &#125; <span class="keyword">from</span> <span class="string">&#x27;antd&#x27;</span>;</span><br><span class="line"><span class="comment">//提交按钮这里 我们会在按钮标签上  htmlType=&quot;submit&quot; 属性 这样就不用在自己写函数 当验证成功的时候 它就会走 onFinish函数 回调里的参数 是 表单输入的值 当验证失败的时候 就会走onFinishFailed参数 </span></span><br><span class="line"><span class="keyword">const</span> Demo = <span class="function">() =&gt;</span> &#123;</span><br><span class="line">  <span class="keyword">const</span> onFinish = <span class="function">(<span class="params">values</span>) =&gt;</span> &#123;</span><br><span class="line">    <span class="built_in">console</span>.log(<span class="string">&#x27;Success:&#x27;</span>, values);</span><br><span class="line">  &#125;;</span><br><span class="line"> <span class="comment">//  验证不同的时候 走此函数</span></span><br><span class="line">  <span class="keyword">const</span> onFinishFailed = <span class="function">(<span class="params">errorInfo</span>) =&gt;</span> &#123;</span><br><span class="line">    <span class="built_in">console</span>.log(<span class="string">&#x27;Failed:&#x27;</span>, errorInfo);</span><br><span class="line">  &#125;;</span><br><span class="line">  <span class="comment">//自定义的验证规则</span></span><br><span class="line">  <span class="keyword">const</span> validUsername=<span class="function">(<span class="params">rule, value, callback</span>)=&gt;</span>&#123;</span><br><span class="line">    <span class="comment">//形参 第一个是验证规则 第二个是 当前验证的值 第三个 是验证通过之后的回调  </span></span><br><span class="line">    <span class="keyword">if</span>(!<span class="regexp">/^(?=.*[a-zA-Z]+)(?=.*[0-9]+)[a-zA-Z0-9]+$/</span>.test(value))&#123;</span><br><span class="line">        callback(<span class="string">&#x27;用户名必须是英文加数字&#x27;</span>)</span><br><span class="line">        <span class="keyword">return</span></span><br><span class="line">    &#125;</span><br><span class="line">    callback()</span><br><span class="line">  &#125;</span><br><span class="line">  </span><br><span class="line">  <span class="keyword">return</span> (</span><br><span class="line">    &lt;Form</span><br><span class="line">      name=<span class="string">&quot;basic&quot;</span></span><br><span class="line">      initialValues=&#123;&#123;</span><br><span class="line">        remember: <span class="literal">true</span>,</span><br><span class="line">      &#125;&#125;</span><br><span class="line">      onFinish=&#123;onFinish&#125;</span><br><span class="line">      onFinishFailed=&#123;onFinishFailed&#125;</span><br><span class="line">    &gt;</span><br><span class="line">      &lt;Form.Item</span><br><span class="line">        <span class="comment">//表单的 label  </span></span><br><span class="line">        label=<span class="string">&quot;Username&quot;</span></span><br><span class="line">        <span class="comment">//控制表单的字段  </span></span><br><span class="line">        name=<span class="string">&quot;username&quot;</span></span><br><span class="line">        <span class="comment">//表单的验证的时机  </span></span><br><span class="line">        validateTrigger=<span class="string">&quot;onBlur&quot;</span></span><br><span class="line">        <span class="comment">//表单的验证规则  </span></span><br><span class="line">        rules=&#123;[</span><br><span class="line">          &#123;</span><br><span class="line">            required: <span class="literal">true</span>,</span><br><span class="line">            message: <span class="string">&#x27;Please input your username!&#x27;</span>,</span><br><span class="line">          &#125;,</span><br><span class="line">          &#123;</span><br><span class="line">              validator:<span class="built_in">this</span>.validUsername</span><br><span class="line">          &#125;</span><br><span class="line">        ]&#125;</span><br><span class="line">      &gt;</span><br><span class="line">        &lt;Input /&gt;</span><br><span class="line">      &lt;/Form.Item&gt;</span><br><span class="line"></span><br><span class="line">      &lt;Form.Item &#123;...tailLayout&#125; name=<span class="string">&quot;remember&quot;</span> valuePropName=<span class="string">&quot;checked&quot;</span>&gt;</span><br><span class="line">        &lt;Checkbox&gt;Remember me&lt;/Checkbox&gt;</span><br><span class="line">      &lt;/Form.Item&gt;</span><br><span class="line"></span><br><span class="line">      &lt;Form.Item &#123;...tailLayout&#125;&gt;</span><br><span class="line">        &lt;Button type=<span class="string">&quot;primary&quot;</span> htmlType=<span class="string">&quot;submit&quot;</span>&gt;</span><br><span class="line">          Submit</span><br><span class="line">        &lt;/Button&gt;</span><br><span class="line">      &lt;/Form.Item&gt;</span><br><span class="line">    &lt;/Form&gt;</span><br><span class="line">  );</span><br><span class="line">&#125;;</span><br><span class="line"><span class="keyword">export</span> <span class="keyword">default</span> Demo</span><br></pre></td></tr></table></figure>
<h3 id="表单的取值-和动态表单项"><a href="#表单的取值-和动态表单项" class="headerlink" title="表单的取值 和动态表单项"></a>表单的取值 和动态表单项</h3><figure class="highlight jsx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>这里我们分为 函数式组件的取值  和 类组件的取值</span><br><span class="line"><span class="number">2.</span>函数式组件的取值 我们用到了hook  类组件的取值我们用到 ref</span><br><span class="line"><span class="number">3.</span>如果有动态表单项 我们可以通过 shouldUpdate 这个属性 来确定 此表单项在什么时候需要显示和隐藏</span><br></pre></td></tr></table></figure>
<figure class="highlight jsx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//函数式 表单的取值 使用 const [form] = Form.useForm() 设置值 使用 form.setFieldsValue 去设置</span></span><br><span class="line"><span class="keyword">import</span> &#123; Form, Input, Button, Select &#125; <span class="keyword">from</span> <span class="string">&#x27;antd&#x27;</span>;</span><br><span class="line"><span class="keyword">const</span> &#123; Option &#125; = Select;</span><br><span class="line"><span class="keyword">const</span> Demo = <span class="function">() =&gt;</span> &#123;</span><br><span class="line">  <span class="comment">//把表单的值 使用hook 搞出来  </span></span><br><span class="line">  <span class="keyword">const</span> [form] = Form.useForm();</span><br><span class="line">  <span class="comment">//这个表单的下拉框选择的事件 每次对应的选择 我们去 设置文本框不同的值</span></span><br><span class="line">  <span class="keyword">const</span> onGenderChange = <span class="function"><span class="params">value</span> =&gt;</span> &#123;</span><br><span class="line">    <span class="keyword">switch</span> (value) &#123;</span><br><span class="line">      <span class="keyword">case</span> <span class="string">&#x27;male&#x27;</span>:</span><br><span class="line">        form.setFieldsValue(&#123; <span class="attr">note</span>: <span class="string">&#x27;Hi, man!&#x27;</span> &#125;);</span><br><span class="line">        <span class="keyword">return</span>;</span><br><span class="line">      <span class="keyword">case</span> <span class="string">&#x27;female&#x27;</span>:</span><br><span class="line">        form.setFieldsValue(&#123; <span class="attr">note</span>: <span class="string">&#x27;Hi, lady!&#x27;</span> &#125;);</span><br><span class="line">        <span class="keyword">return</span>;</span><br><span class="line">      <span class="keyword">case</span> <span class="string">&#x27;other&#x27;</span>:</span><br><span class="line">        form.setFieldsValue(&#123; <span class="attr">note</span>: <span class="string">&#x27;Hi there!&#x27;</span> &#125;);</span><br><span class="line">        <span class="keyword">return</span>;</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;;</span><br><span class="line"></span><br><span class="line">  <span class="keyword">const</span> onFinish = <span class="function"><span class="params">values</span> =&gt;</span> &#123;</span><br><span class="line">    <span class="built_in">console</span>.log(values);</span><br><span class="line">  &#125;;</span><br><span class="line"></span><br><span class="line">  <span class="keyword">const</span> onReset = <span class="function">() =&gt;</span> &#123;</span><br><span class="line">    form.resetFields();</span><br><span class="line">  &#125;;</span><br><span class="line"></span><br><span class="line">  <span class="keyword">const</span> onFill = <span class="function">() =&gt;</span> &#123;</span><br><span class="line">    form.setFieldsValue(&#123;</span><br><span class="line">      note: <span class="string">&#x27;Hello world!&#x27;</span>,</span><br><span class="line">      gender: <span class="string">&#x27;male&#x27;</span>,</span><br><span class="line">    &#125;);</span><br><span class="line">  &#125;;</span><br><span class="line"></span><br><span class="line">  <span class="keyword">return</span> (</span><br><span class="line">    &lt;Form &#123;...layout&#125; form=&#123;form&#125; name=<span class="string">&quot;control-hooks&quot;</span> onFinish=&#123;onFinish&#125;&gt;</span><br><span class="line">      &lt;Form.Item name=<span class="string">&quot;note&quot;</span> label=<span class="string">&quot;Note&quot;</span> rules=&#123;[&#123; <span class="attr">required</span>: <span class="literal">true</span> &#125;]&#125;&gt;</span><br><span class="line">        &lt;Input /&gt;</span><br><span class="line">      &lt;/Form.Item&gt;</span><br><span class="line">      &lt;Form.Item name=<span class="string">&quot;gender&quot;</span> label=<span class="string">&quot;Gender&quot;</span> rules=&#123;[&#123; <span class="attr">required</span>: <span class="literal">true</span> &#125;]&#125;&gt;</span><br><span class="line">        &lt;Select</span><br><span class="line">          placeholder=<span class="string">&quot;Select a option and change input text above&quot;</span></span><br><span class="line">          onChange=&#123;onGenderChange&#125;</span><br><span class="line">          allowClear</span><br><span class="line">        &gt;</span><br><span class="line">          &lt;Option value=<span class="string">&quot;male&quot;</span>&gt;male&lt;/Option&gt;</span><br><span class="line">          &lt;Option value=<span class="string">&quot;female&quot;</span>&gt;female&lt;/Option&gt;</span><br><span class="line">          &lt;Option value=<span class="string">&quot;other&quot;</span>&gt;other&lt;/Option&gt;</span><br><span class="line">        &lt;/Select&gt;</span><br><span class="line">      &lt;/Form.Item&gt;</span><br><span class="line">      &#123;<span class="comment">/*最开始的时候 这个 表单项是隐藏的 只有 我上一次的gender的字段的值 不等于 我现在的gender的字段的值 我才		去显示 我这个表单项 返回了true 和false</span></span><br><span class="line"><span class="comment">      */</span>&#125;    </span><br><span class="line">      &lt;Form.Item</span><br><span class="line">        noStyle</span><br><span class="line">        shouldUpdate=&#123;<span class="function">(<span class="params">prevValues, currentValues</span>) =&gt;</span> &#123;</span><br><span class="line">            <span class="keyword">return</span> prevValues.gender !== currentValues.gender</span><br><span class="line">        &#125;&#125;</span><br><span class="line">      &gt;</span><br><span class="line">          &#123;<span class="comment">/*这个就是 看看 我gender字段的值等于 other 如果等于 我就渲染这个表单项*/</span>&#125;</span><br><span class="line">        &#123;<span class="function">(<span class="params">&#123; getFieldValue &#125;</span>) =&gt;</span> &#123;</span><br><span class="line">          <span class="keyword">return</span> getFieldValue(<span class="string">&#x27;gender&#x27;</span>) === <span class="string">&#x27;other&#x27;</span> ? (</span><br><span class="line">            &lt;Form.Item name=<span class="string">&quot;customizeGender&quot;</span> label=<span class="string">&quot;Customize Gender&quot;</span> rules=&#123;[&#123; <span class="attr">required</span>: <span class="literal">true</span> &#125;]&#125;&gt;</span><br><span class="line">              &lt;Input /&gt;</span><br><span class="line">            &lt;/Form.Item&gt;</span><br><span class="line">          ) : <span class="literal">null</span>;</span><br><span class="line">        &#125;&#125;</span><br><span class="line">      &lt;/Form.Item&gt;</span><br><span class="line">      &lt;Form.Item &#123;...tailLayout&#125;&gt;</span><br><span class="line">        &lt;Button type=<span class="string">&quot;primary&quot;</span> htmlType=<span class="string">&quot;submit&quot;</span>&gt;</span><br><span class="line">          Submit</span><br><span class="line">        &lt;/Button&gt;</span><br><span class="line">        &lt;Button htmlType=<span class="string">&quot;button&quot;</span> onClick=&#123;onReset&#125;&gt;</span><br><span class="line">          Reset</span><br><span class="line">        &lt;/Button&gt;</span><br><span class="line">        &lt;Button type=<span class="string">&quot;link&quot;</span> htmlType=<span class="string">&quot;button&quot;</span> onClick=&#123;onFill&#125;&gt;</span><br><span class="line">          Fill form</span><br><span class="line">        &lt;/Button&gt;</span><br><span class="line">      &lt;/Form.Item&gt;</span><br><span class="line">    &lt;/Form&gt;</span><br><span class="line">  );</span><br><span class="line">&#125;;</span><br><span class="line"></span><br><span class="line"><span class="keyword">export</span> <span class="keyword">default</span> Demo</span><br></pre></td></tr></table></figure>
<figure class="highlight jsx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//类组件的 表单 取值 通过 formRef = React.createRef() 去取值 在Form组件上 绑定ref去实现 通过this.formRef.current.setFieldsValue可以设置表单的值 上面还有一些其他的方法 具体可以参考文档</span></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">Demo</span> <span class="keyword">extends</span> <span class="title">React</span>.<span class="title">Component</span> </span>&#123;</span><br><span class="line">  <span class="comment">//通过ref的引用 来获取了 表单的值  </span></span><br><span class="line">  formRef = React.createRef();</span><br><span class="line">  onGenderChange = <span class="function">(<span class="params">value</span>) =&gt;</span> &#123;</span><br><span class="line">    <span class="keyword">switch</span> (value) &#123;</span><br><span class="line">      <span class="keyword">case</span> <span class="string">&#x27;male&#x27;</span>:</span><br><span class="line">        <span class="built_in">this</span>.formRef.current.setFieldsValue(&#123;</span><br><span class="line">          note: <span class="string">&#x27;Hi, man!&#x27;</span>,</span><br><span class="line">        &#125;);</span><br><span class="line">        <span class="keyword">return</span>;</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;;</span><br><span class="line">  <span class="function"><span class="title">render</span>(<span class="params"></span>)</span> &#123;</span><br><span class="line">    <span class="keyword">return</span> (</span><br><span class="line">      &lt;Form ref=&#123;<span class="built_in">this</span>.formRef&#125; &gt;</span><br><span class="line">        &lt;Form.Item</span><br><span class="line">          name=<span class="string">&quot;note&quot;</span></span><br><span class="line">          label=<span class="string">&quot;Note&quot;</span></span><br><span class="line">        &gt;</span><br><span class="line">          &lt;Input /&gt;</span><br><span class="line">        &lt;/Form.Item&gt;</span><br><span class="line">        &lt;Form.Item</span><br><span class="line">          name=<span class="string">&quot;gender&quot;</span></span><br><span class="line">          label=<span class="string">&quot;Gender&quot;</span></span><br><span class="line">        &gt;</span><br><span class="line">          &lt;Select</span><br><span class="line">            placeholder=<span class="string">&quot;Select a option and change input text above&quot;</span></span><br><span class="line">            onChange=&#123;<span class="built_in">this</span>.onGenderChange&#125;</span><br><span class="line">            allowClear</span><br><span class="line">          &gt;</span><br><span class="line">            &lt;Option value=<span class="string">&quot;male&quot;</span>&gt;male&lt;/Option&gt;</span><br><span class="line">            &lt;Option value=<span class="string">&quot;female&quot;</span>&gt;female&lt;/Option&gt;</span><br><span class="line">            &lt;Option value=<span class="string">&quot;other&quot;</span>&gt;other&lt;/Option&gt;</span><br><span class="line">          &lt;/Select&gt;</span><br><span class="line">        &lt;/Form.Item&gt;</span><br><span class="line">        &lt;Form.Item</span><br><span class="line">          noStyle</span><br><span class="line">          shouldUpdate=&#123;<span class="function">(<span class="params">prevValues, currentValues</span>) =&gt;</span> prevValues.gender !== currentValues.gender&#125;</span><br><span class="line">        &gt;</span><br><span class="line">          &#123;<span class="function">(<span class="params">&#123; getFieldValue &#125;</span>) =&gt;</span> &#123;</span><br><span class="line">            <span class="keyword">return</span> getFieldValue(<span class="string">&#x27;gender&#x27;</span>) === <span class="string">&#x27;other&#x27;</span> ? (</span><br><span class="line">              &lt;Form.Item</span><br><span class="line">                name=<span class="string">&quot;customizeGender&quot;</span></span><br><span class="line">                label=<span class="string">&quot;Customize Gender&quot;</span></span><br><span class="line">                rules=&#123;[</span><br><span class="line">                  &#123;</span><br><span class="line">                    required: <span class="literal">true</span>,</span><br><span class="line">                  &#125;,</span><br><span class="line">                ]&#125;</span><br><span class="line">              &gt;</span><br><span class="line">                &lt;Input /&gt;</span><br><span class="line">              &lt;/Form.Item&gt;</span><br><span class="line">            ) : <span class="literal">null</span>;</span><br><span class="line">          &#125;&#125;</span><br><span class="line">        &lt;/Form.Item&gt;</span><br><span class="line">        &lt;Form.Item &#123;...tailLayout&#125;&gt;</span><br><span class="line">          &lt;Button type=<span class="string">&quot;primary&quot;</span> htmlType=<span class="string">&quot;submit&quot;</span>&gt;</span><br><span class="line">            Submit</span><br><span class="line">          &lt;/Button&gt;</span><br><span class="line">          &lt;Button htmlType=<span class="string">&quot;button&quot;</span> onClick=&#123;<span class="built_in">this</span>.onReset&#125;&gt;</span><br><span class="line">            Reset</span><br><span class="line">          &lt;/Button&gt;</span><br><span class="line">          &lt;Button type=<span class="string">&quot;link&quot;</span> htmlType=<span class="string">&quot;button&quot;</span> onClick=&#123;<span class="built_in">this</span>.onFill&#125;&gt;</span><br><span class="line">            Fill form</span><br><span class="line">          &lt;/Button&gt;</span><br><span class="line">        &lt;/Form.Item&gt;</span><br><span class="line">      &lt;/Form&gt;</span><br><span class="line">    );</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h2 id="函数式组件的使用"><a href="#函数式组件的使用" class="headerlink" title="函数式组件的使用"></a>函数式组件的使用</h2><figure class="highlight jsx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>这里我们主要是写的一个一个的钩子比如列表的时候 我们如果去初始化数据</span><br><span class="line"><span class="number">2.</span>当编辑跳转到详情的时候 我们怎么去去初始化数据</span><br></pre></td></tr></table></figure>
<h3 id="useEffect的使用"><a href="#useEffect的使用" class="headerlink" title="useEffect的使用"></a>useEffect的使用</h3><figure class="highlight jsx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>我们在类组件的时候 每当这个组件加载的时候 就需要去请求列表的数据 这动作是在 componentDidMount生命周期去完成的</span><br><span class="line"><span class="number">2.</span>我们在 函数式组件的时候 要使用 useEffect 让函数式组件一开始调用的时候就要走一次这个useEffect这个函数</span><br><span class="line"><span class="number">3.</span>useEffect 是一个函数 第一个参数 是一个回调函数 你要做的事情 第二个函数 是一个数据的初始状态</span><br></pre></td></tr></table></figure>
<figure class="highlight jsx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//列表获取数据</span></span><br><span class="line"><span class="keyword">import</span> React, &#123; useEffect, useState &#125; <span class="keyword">from</span> <span class="string">&quot;react&quot;</span>;</span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">List</span>(<span class="params">props</span>) </span>&#123;</span><br><span class="line">  <span class="built_in">console</span>.log(props);</span><br><span class="line">  <span class="comment">// 定义局部状态</span></span><br><span class="line">  <span class="comment">// const [dataSource, setDataSource] = useState([]);</span></span><br><span class="line">  <span class="comment">// const [total, setTotal] = useState(0);</span></span><br><span class="line">  <span class="comment">// const [currentPage, setCurrentPage] = useState(1);</span></span><br><span class="line"></span><br><span class="line">  <span class="keyword">const</span> &#123; list, page, total &#125; = props;</span><br><span class="line">  <span class="comment">//一开始的时候 我们就向reducer里发送数据</span></span><br><span class="line">  useEffect(<span class="function">() =&gt;</span> &#123;</span><br><span class="line">    props.dispatch(</span><br><span class="line">      loadProduct(&#123;</span><br><span class="line">        page: <span class="number">1</span></span><br><span class="line">        <span class="comment">// name: &quot;小米&quot;</span></span><br><span class="line">      &#125;)</span><br><span class="line">    );</span><br><span class="line">  &#125;, []);</span><br><span class="line"></span><br><span class="line">  <span class="keyword">const</span> loadData = <span class="function">() =&gt;</span> &#123;</span><br><span class="line">    props.dispatch(</span><br><span class="line">      loadProduct(&#123;</span><br><span class="line">        page: page</span><br><span class="line">        <span class="comment">// name: &quot;小米&quot;</span></span><br><span class="line">      &#125;)</span><br><span class="line">    );</span><br><span class="line">  &#125;;</span><br><span class="line">  <span class="keyword">return</span> (</span><br><span class="line">      &lt;Table</span><br><span class="line">        rowKey=<span class="string">&quot;_id&quot;</span></span><br><span class="line">        rowClassName=&#123;<span class="function"><span class="params">record</span> =&gt;</span> (record.onSale ? <span class="string">&quot;&quot;</span> : <span class="string">&quot;bg-red&quot;</span>)&#125;</span><br><span class="line">        pagination=&#123;&#123;</span><br><span class="line">          total,</span><br><span class="line">          defaultPageSize: <span class="number">2</span>,</span><br><span class="line">          onChange: <span class="function"><span class="params">p</span> =&gt;</span> &#123;</span><br><span class="line">            props.dispatch(loadProduct(&#123; <span class="attr">page</span>: p &#125;));</span><br><span class="line">          &#125;</span><br><span class="line">        &#125;&#125;</span><br><span class="line">        columns=&#123;columns&#125;</span><br><span class="line">        bordered</span><br><span class="line">        dataSource=&#123;list&#125;</span><br><span class="line">      /&gt;</span><br><span class="line">  );</span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">export</span> <span class="keyword">default</span> connect(<span class="function"><span class="params">state</span> =&gt;</span> state.product)(List);</span><br></pre></td></tr></table></figure>
<h3 id="useState-的使用"><a href="#useState-的使用" class="headerlink" title="useState 的使用"></a>useState 的使用</h3><figure class="highlight jsx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>可以让 函数式组件 拥有了自己的状态</span><br><span class="line"><span class="number">2.</span>比如 我们 从列表的编辑跳转到 编辑的详情页的时候  需要 从库里去查询ID 然后赋值给我们详情的表单</span><br></pre></td></tr></table></figure>
<figure class="highlight jsx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> React, &#123; useState, useEffect &#125; <span class="keyword">from</span> <span class="string">&quot;react&quot;</span>;</span><br><span class="line"><span class="keyword">import</span> &#123; Form, Card, Input, Button, message, Upload, Icon &#125; <span class="keyword">from</span> <span class="string">&quot;antd&quot;</span>;</span><br><span class="line"><span class="keyword">import</span> &#123; createApi, getOneById, modifyOne &#125; <span class="keyword">from</span> <span class="string">&quot;../../../services/products&quot;</span>;</span><br><span class="line"><span class="keyword">import</span> &#123; serverUrl &#125; <span class="keyword">from</span> <span class="string">&quot;../../../utils/config&quot;</span>;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">Edit</span>(<span class="params">props</span>) </span>&#123;</span><br><span class="line"></span><br><span class="line">  <span class="comment">//设置表单的值</span></span><br><span class="line">  <span class="keyword">const</span> [currentData, setCurrentData] = useState(&#123;&#125;);</span><br><span class="line"></span><br><span class="line">  <span class="comment">// 初始化的时候执行</span></span><br><span class="line">  useEffect(<span class="function">() =&gt;</span> &#123;</span><br><span class="line">    <span class="comment">//去查询 当前的详情  </span></span><br><span class="line">    <span class="keyword">if</span> (props.match.params.id) &#123;</span><br><span class="line">      getOneById(props.match.params.id).then(<span class="function"><span class="params">res</span> =&gt;</span> &#123;</span><br><span class="line">        <span class="comment">//把查询结果 通过  setCurrentData(我们useState结构出来的方法) 来设置我们表单的值</span></span><br><span class="line">        setCurrentData(res);</span><br><span class="line">        setImageUrl(res.coverImg);</span><br><span class="line">        setEditorState(BraftEditor.createEditorState(res.content));</span><br><span class="line">      &#125;);</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;, []);</span><br><span class="line"></span><br><span class="line">  <span class="keyword">return</span> (</span><br><span class="line">      &lt;Form onSubmit=&#123;<span class="function"><span class="params">e</span> =&gt;</span> handleSubmit(e)&#125;&gt;</span><br><span class="line">        &lt;Form.Item label=<span class="string">&quot;名字&quot;</span>&gt;</span><br><span class="line">          &#123;getFieldDecorator(<span class="string">&quot;name&quot;</span>, &#123;</span><br><span class="line">            rules: [</span><br><span class="line">              &#123;</span><br><span class="line">                required: <span class="literal">true</span>,</span><br><span class="line">                message: <span class="string">&quot;请输入商品名字&quot;</span></span><br><span class="line">              &#125;</span><br><span class="line">            ],</span><br><span class="line">            <span class="comment">//设立就是这是了默认的初始值    </span></span><br><span class="line">            initialValue: currentData.name</span><br><span class="line">          &#125;)(<span class="xml"><span class="tag">&lt;<span class="name">Input</span> <span class="attr">placeholder</span>=<span class="string">&quot;请输入商品名字&quot;</span> /&gt;</span></span>)&#125;</span><br><span class="line">        &lt;/Form.Item&gt;</span><br><span class="line">        &lt;Form.Item&gt;</span><br><span class="line">          &lt;Button htmlType=<span class="string">&quot;submit&quot;</span> type=<span class="string">&quot;primary&quot;</span>&gt;</span><br><span class="line">            保存</span><br><span class="line">          &lt;/Button&gt;</span><br><span class="line">        &lt;/Form.Item&gt;</span><br><span class="line">      &lt;/Form&gt;</span><br><span class="line">  );</span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">export</span> <span class="keyword">default</span> Form.create(&#123; <span class="attr">name</span>: <span class="string">&quot;productEdit&quot;</span> &#125;)(Edit);</span><br></pre></td></tr></table></figure>
</article><div class="post-copyright"><div class="post-copyright__title"><span class="post-copyright-info"><h>Ant Design 组件使用随笔</h></span></div><div class="post-copyright__type"><span class="post-copyright-info"><a href="http://example.com/2019/03/21/react-antd%E9%9A%8F%E7%AC%94/">http://example.com/2019/03/21/react-antd%E9%9A%8F%E7%AC%94/</a></span></div><div class="post-copyright-m"><div class="post-copyright-m-info"><div class="post-copyright-a"><h>作者</h><div class="post-copyright-cc-info"><h>北城韩雨</h></div></div><div class="post-copyright-c"><h>发布于</h><div class="post-copyright-cc-info"><h>2019-03-21</h></div></div><div class="post-copyright-u"><h>更新于</h><div class="post-copyright-cc-info"><h>2019-06-03</h></div></div><div class="post-copyright-c"><h>许可协议</h><div class="post-copyright-cc-info"><a class="icon" rel="noopener" target="_blank" title="Creative Commons" href="https://creativecommons.org/"><i class="fab fa-creative-commons"></i></a><a rel="noopener" target="_blank" title="CC BY-NC-SA 4.0" href="https://creativecommons.org/licenses/by-nc-sa/4.0/">CC BY-NC-SA 4.0</a></div></div></div></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/Ant-Design/">Ant Design</a></div><div class="post_share"></div></div><link rel="stylesheet" href="/" media="defer" onload="this.media='all'"/><div class="post-reward"><button class="tip-button reward-button"><span class="tip-button__text">打赏</span><div class="coin-wrapper"><div class="coin"><div class="coin__middle"></div><div class="coin__back"></div><div class="coin__front"></div></div></div><div class="reward-main"><ul class="reward-all"><li class="reward-item"><a href="/img/weixin.jpg" target="_blank"><img class="post-qr-code-img" src="/img/weixin.jpg" alt="微信"/></a><div class="post-qr-code-desc">微信</div></li><li class="reward-item"><a href="/img/taobao.jpg" target="_blank"><img class="post-qr-code-img" src="/img/taobao.jpg" alt="支付宝"/></a><div class="post-qr-code-desc">支付宝</div></li></ul></div></button></div><script defer="defer" src="/"></script><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/2019/03/21/%E5%89%8D%E7%AB%AF%E6%80%A7%E8%83%BD%E4%BC%98%E5%8C%96/"><img class="prev-cover" src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic.vjshi.com%2F2018-07-17%2Faf41dabad727ba80c9ca8a2bfbd22a58%2F00004.jpg%3Fx-oss-process%3Dstyle%2Fwatermark&amp;refer=http%3A%2F%2Fpic.vjshi.com&amp;app=2002&amp;size=f9999,10000&amp;q=a80&amp;n=0&amp;g=0n&amp;fmt=jpeg?sec=1629530659&amp;t=bbcfe1e86f393eecbb0722db1b92e475" onerror="onerror=null;src='/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">前端性能优化</div></div></a></div><div class="next-post pull-right"><a href="/2019/03/20/Vue%E6%80%A7%E8%83%BD%E4%BC%98%E5%8C%96/"><img class="next-cover" src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic.vjshi.com%2F2018-07-17%2Faf41dabad727ba80c9ca8a2bfbd22a58%2F00004.jpg%3Fx-oss-process%3Dstyle%2Fwatermark&amp;refer=http%3A%2F%2Fpic.vjshi.com&amp;app=2002&amp;size=f9999,10000&amp;q=a80&amp;n=0&amp;g=0n&amp;fmt=jpeg?sec=1629530659&amp;t=bbcfe1e86f393eecbb0722db1b92e475" onerror="onerror=null;src='/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">Vue性能优化</div></div></a></div></nav></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="/img/my.jpg" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">北城韩雨</div><div class="author-info__description">一个前端界的小学生</div></div><div class="card-info-data"><div class="card-info-data-item is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">65</div></a></div><div class="card-info-data-item is-center"><a href="/tags/"><div class="headline">标签</div><div class="length-num">23</div></a></div><div class="card-info-data-item is-center"><a href="/categories/"><div class="headline">分类</div><div class="length-num">21</div></a></div></div><a class="button--animated" id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/wazer1987"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="/wangzhengvslike@163.com" target="_blank" title="Email"><i class="fas fa-envelope"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn card-announcement-animation"></i><span>公告</span></div><div class="announcement_content"><p>感谢访问本站，如喜欢请收藏。本站主要分享前端知识，立志成为资深前端工程师，但目前是一个前端界的小学生 若喜欢可以打赏请博主喝一杯冰阔落</p> <p>另外请大家多多支持淼哥的开源项目</p> <p>https://github.com/flipped-aurora/gin-vue-admin</p> <p>🌟🌟欢迎大家start 🌟🌟</p> <p>欢迎加入博主的前端技术交流群</p> <p style="background:rgba(255,255,255,1);margin:0"> <img src="/img/code.png"></img> </p></div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#Ant-Design-%E7%BB%84%E4%BB%B6%E4%BD%BF%E7%94%A8%E9%9A%8F%E7%AC%94"><span class="toc-text">Ant Design 组件使用随笔</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%90%8E%E5%8F%B0%E7%AE%A1%E7%90%86%E7%9A%84%E8%B7%AF%E7%94%B1"><span class="toc-text">后台管理的路由</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#index-jsx-%E6%96%87%E4%BB%B6"><span class="toc-text">index.jsx 文件</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#App-jsx-%E6%96%87%E4%BB%B6"><span class="toc-text">App.jsx 文件</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Frame-jsx"><span class="toc-text">Frame.jsx</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%88%97%E8%A1%A8%E9%A1%B5"><span class="toc-text">列表页</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%85%8D%E7%BD%AE"><span class="toc-text">配置</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%8A%A8%E4%BD%9C%E6%8C%89%E9%92%AE"><span class="toc-text">动作按钮</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%88%86%E9%A1%B5"><span class="toc-text">分页</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%A1%A8%E5%A4%B4%E7%9A%84%E6%8B%96%E6%8B%BD"><span class="toc-text">表头的拖拽</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E8%A1%A8%E5%8D%95%E9%A1%B5"><span class="toc-text">表单页</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%A1%A8%E5%8D%95%E7%9A%84%E9%85%8D%E7%BD%AE"><span class="toc-text">表单的配置</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%A1%A8%E5%8D%95%E7%9A%84%E9%AA%8C%E8%AF%81"><span class="toc-text">表单的验证</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%A1%A8%E5%8D%95%E7%9A%84%E5%8F%96%E5%80%BC-%E5%92%8C%E5%8A%A8%E6%80%81%E8%A1%A8%E5%8D%95%E9%A1%B9"><span class="toc-text">表单的取值 和动态表单项</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%87%BD%E6%95%B0%E5%BC%8F%E7%BB%84%E4%BB%B6%E7%9A%84%E4%BD%BF%E7%94%A8"><span class="toc-text">函数式组件的使用</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#useEffect%E7%9A%84%E4%BD%BF%E7%94%A8"><span class="toc-text">useEffect的使用</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#useState-%E7%9A%84%E4%BD%BF%E7%94%A8"><span class="toc-text">useState 的使用</span></a></li></ol></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/2021/04/16/gin-vue-admin/" title="Gin-Vue-Admin"><img src="/img/gin-vue-admin.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Gin-Vue-Admin"/></a><div class="content"><a class="title" href="/2021/04/16/gin-vue-admin/" title="Gin-Vue-Admin">Gin-Vue-Admin</a><time datetime="2021-04-15T16:00:00.000Z" title="发表于 2021-04-16 00:00:00">2021-04-16</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/01/08/Vue%E6%BA%90%E7%A0%81%E5%BC%80%E5%8F%91%E4%B9%8B%E7%BB%84%E4%BB%B6%E7%9A%84%E6%B8%B2%E6%9F%9310/" title="Vue源码开发-组件的渲染10"><img src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic.vjshi.com%2F2018-07-17%2F3eca5394963b50e37b7be2ba320029ec%2F00003.jpg%3Fx-oss-process%3Dstyle%2Fwatermark&amp;refer=http%3A%2F%2Fpic.vjshi.com&amp;app=2002&amp;size=f9999,10000&amp;q=a80&amp;n=0&amp;g=0n&amp;fmt=jpeg?sec=1629530644&amp;t=10679b5732c52e39eeb588040240a790" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Vue源码开发-组件的渲染10"/></a><div class="content"><a class="title" href="/2021/01/08/Vue%E6%BA%90%E7%A0%81%E5%BC%80%E5%8F%91%E4%B9%8B%E7%BB%84%E4%BB%B6%E7%9A%84%E6%B8%B2%E6%9F%9310/" title="Vue源码开发-组件的渲染10">Vue源码开发-组件的渲染10</a><time datetime="2021-01-07T16:00:00.000Z" title="发表于 2021-01-08 00:00:00">2021-01-08</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/01/07/Vue%E6%BA%90%E7%A0%81%E5%BC%80%E5%8F%91%E4%B9%8B%E7%BB%84%E4%BB%B6%E7%9A%84%E5%90%88%E5%B9%B6%E7%AD%96%E7%95%A509/" title="Vue源码开发-组件合并策略09"><img src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fcz-video-photo.oss-cn-beijing.aliyuncs.com%2F20191017%2F4cfc341591d242327b67e9ceb6953612_00002.jpg&amp;refer=http%3A%2F%2Fcz-video-photo.oss-cn-beijing.aliyuncs.com&amp;app=2002&amp;size=f9999,10000&amp;q=a80&amp;n=0&amp;g=0n&amp;fmt=jpeg?sec=1629530702&amp;t=80943e12d5239f63beafd6d1c540855f" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Vue源码开发-组件合并策略09"/></a><div class="content"><a class="title" href="/2021/01/07/Vue%E6%BA%90%E7%A0%81%E5%BC%80%E5%8F%91%E4%B9%8B%E7%BB%84%E4%BB%B6%E7%9A%84%E5%90%88%E5%B9%B6%E7%AD%96%E7%95%A509/" title="Vue源码开发-组件合并策略09">Vue源码开发-组件合并策略09</a><time datetime="2021-01-06T16:00:00.000Z" title="发表于 2021-01-07 00:00:00">2021-01-07</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/01/06/Vue%E6%BA%90%E7%A0%81%E5%BC%80%E5%8F%91%E4%B9%8B%E6%95%B0%E7%BB%84%E7%9A%84%E4%BE%9D%E8%B5%96%E6%94%B6%E9%9B%8608/" title="Vue源码开发-数组的依赖收集08"><img src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic.vjshi.com%2F2018-07-17%2F3eca5394963b50e37b7be2ba320029ec%2F00003.jpg%3Fx-oss-process%3Dstyle%2Fwatermark&amp;refer=http%3A%2F%2Fpic.vjshi.com&amp;app=2002&amp;size=f9999,10000&amp;q=a80&amp;n=0&amp;g=0n&amp;fmt=jpeg?sec=1629530644&amp;t=10679b5732c52e39eeb588040240a790" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Vue源码开发-数组的依赖收集08"/></a><div class="content"><a class="title" href="/2021/01/06/Vue%E6%BA%90%E7%A0%81%E5%BC%80%E5%8F%91%E4%B9%8B%E6%95%B0%E7%BB%84%E7%9A%84%E4%BE%9D%E8%B5%96%E6%94%B6%E9%9B%8608/" title="Vue源码开发-数组的依赖收集08">Vue源码开发-数组的依赖收集08</a><time datetime="2021-01-05T16:00:00.000Z" title="发表于 2021-01-06 00:00:00">2021-01-06</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/01/06/Vue%E6%BA%90%E7%A0%81%E5%BC%80%E5%8F%91%E4%B9%8B%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F%E5%90%88%E5%B9%B607/" title="Vue源码开发-生命周期合并07"><img src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic.vjshi.com%2F2018-07-17%2Faf41dabad727ba80c9ca8a2bfbd22a58%2F00004.jpg%3Fx-oss-process%3Dstyle%2Fwatermark&amp;refer=http%3A%2F%2Fpic.vjshi.com&amp;app=2002&amp;size=f9999,10000&amp;q=a80&amp;n=0&amp;g=0n&amp;fmt=jpeg?sec=1629530659&amp;t=bbcfe1e86f393eecbb0722db1b92e475" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Vue源码开发-生命周期合并07"/></a><div class="content"><a class="title" href="/2021/01/06/Vue%E6%BA%90%E7%A0%81%E5%BC%80%E5%8F%91%E4%B9%8B%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F%E5%90%88%E5%B9%B607/" title="Vue源码开发-生命周期合并07">Vue源码开发-生命周期合并07</a><time datetime="2021-01-05T16:00:00.000Z" title="发表于 2021-01-06 00:00:00">2021-01-06</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright"><span>&copy;2017 - 2021</span><svg style="width:2em; height:2em;position: relative;top: 10px;" aria-hidden="true"><use xlink:href="#icon-Butterfly"></use></svg><span>北城韩雨</span></div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div><div class="footer_custom_text"><p><a style="margin-inline:5px" target="_blank" href="https://hexo.io/"><img src="https://img.shields.io/badge/Frame-Hexo-blue?style=flat&logo=hexo" title="博客框架为Hexo"></a><a style="margin-inline:5px" target="_blank" href="https://butterfly.js.org/"><img src="https://img.shields.io/badge/Theme-Butterfly-6513df?style=flat&logo=bitdefender" title="主题采用butterfly"></a><a style="margin-inline:5px" target="_blank" href="https://www.jsdelivr.com/"><img src="https://img.shields.io/badge/CDN-jsDelivr-orange?style=flat&logo=jsDelivr" title="本站使用JsDelivr为静态资源提供CDN加速"></a></p></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/medium-zoom/dist/medium-zoom.min.js"></script><div class="js-pjax"></div><script defer src="/live2d-widget/autoload.js"></script><script src="/js/coin.js"></script><script async src="//at.alicdn.com/t/font_2700632_3rtvhzzpl3h.js"></script><script src="/js/liuxing.js" data-pjax></script><canvas class="fireworks" mobile="false"></canvas><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/fireworks.min.js"></script><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/activate-power-mode.min.js"></script><script>POWERMODE.colorful = true;
POWERMODE.shake = true;
POWERMODE.mobile = false;
document.body.addEventListener('input', POWERMODE);
</script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div><!-- hexo injector body_end start --><div class="js-pjax"><script async="async">var arr = document.getElementsByClassName('recent-post-item');
for(var i = 0;i<arr.length;i++){
    arr[i].classList.add('wow');
    arr[i].classList.add('animate__zoomIn');
    arr[i].setAttribute('data-wow-duration', '1s');
    arr[i].setAttribute('data-wow-delay', '0ms');
    arr[i].setAttribute('data-wow-offset', '100');
    arr[i].setAttribute('data-wow-iteration', '1');
  }</script><script async="async">var arr = document.getElementsByClassName('card-widget');
for(var i = 0;i<arr.length;i++){
    arr[i].classList.add('wow');
    arr[i].classList.add('animate__zoomIn');
    arr[i].setAttribute('data-wow-duration', '');
    arr[i].setAttribute('data-wow-delay', '');
    arr[i].setAttribute('data-wow-offset', '');
    arr[i].setAttribute('data-wow-iteration', '');
  }</script></div><script defer src="https://cdn.jsdelivr.net/gh/graingert/wow@1.3.0/dist/wow.min.js"></script><script defer src="https://cdn.jsdelivr.net/npm/hexo-butterfly-wowjs/lib/wow_init.min.js"></script><script async src="//at.alicdn.com/t/font_2032782_8d5kxvn09md.js"></script><!-- hexo injector body_end end --></body></html>